module.exports = (app, router) => {
    const article = require("../../models/article");
    const articleType = require('../../models/articleType')
    const comment = require('../../models/comment')
    const { requestResult } = require('../../plugins/index')

    router.get('/info', async(req, res) => {
        const result = await Promise.all([
            article.countDocuments(),
            articleType.countDocuments(),
            comment.countDocuments()
        ])
        const key = ['article','articleType','comment']
        const data = key.reduce((total, val, index) => {
            total[val] = result[index]
            return total
        },{})
        res.send(requestResult(data))
    })

    app.use('/admin/api', router)
}